<?php
/**
 *============================================================================
 * Cornice PHP Framework & Website Builder
 * Freeware (f) 2011 by Inforo Software & Computer
 *============================================================================
 */
 
/**
 * Class contains miscellaneous utils for XML
 * @author Nicola Dinh
 * @version 2011.04.2217
 */
class xml {

  /**
   * Default instance level constructor
   * Just decorative, should not be called due to having only static methods
   */
  public function __construct() {
    //
  }
  
  /**
   * Parse XML text into array 
   * @param string $xml_text The XML text to be parsed
   * @return array The array containing values (root tag included)
   */
  public static function parse_text($xml_text) { 
    $xml_obj = simplexml_load_string($xml_text); 
    return utils::obj_to_arr($xml_obj);
  }
  
  /**
   * Load a XML file and parse to array
   * @param string $file_path The file path to XML file
   * @return array The correspoding array to that XML
   */
  public static function arr_from_file($file_path) { 
    $xml_text = file_get_contents($file_path); 
    return self::parse_text($xml_text);
  }
}
  